﻿'use strict';
app.controller('MorrisCtrl', [
    '$rootScope', '$scope', function ($rootScope, $scope) {

        $scope.tax_data = [
            { "period": "2011 Q3", "licensed": 3407, "sorned": 660 },
            { "period": "2011 Q2", "licensed": 3351, "sorned": 629 },
            { "period": "2011 Q1", "licensed": 3269, "sorned": 618 },
            { "period": "2010 Q4", "licensed": 3246, "sorned": 661 },
            { "period": "2009 Q4", "licensed": 3171, "sorned": 676 },
            { "period": "2008 Q4", "licensed": 3155, "sorned": 681 },
            { "period": "2007 Q4", "licensed": 3226, "sorned": 620 },
            { "period": "2006 Q4", "licensed": 3245, "sorned": null },
            { "period": "2005 Q4", "licensed": 3289, "sorned": null }
        ];


        Morris.Area({
            element: 'area-chart',
            data: [
                { period: '2010 Q1', iphone: 2666, ipad: null, itouch: 2647 },
                { period: '2010 Q2', iphone: 2778, ipad: 2294, itouch: 2441 },
                { period: '2010 Q3', iphone: 4912, ipad: 1969, itouch: 2501 },
                { period: '2010 Q4', iphone: 3767, ipad: 3597, itouch: 5689 },
                { period: '2011 Q1', iphone: 6810, ipad: 1914, itouch: 2293 },
                { period: '2011 Q2', iphone: 5670, ipad: 4293, itouch: 1881 },
                { period: '2011 Q3', iphone: 4820, ipad: 3795, itouch: 1588 },
                { period: '2011 Q4', iphone: 15073, ipad: 5967, itouch: 5175 },
                { period: '2012 Q1', iphone: 10687, ipad: 4460, itouch: 2028 },
                { period: '2012 Q2', iphone: 8432, ipad: 5713, itouch: 1791 }
            ],
            xkey: 'period',
            ykeys: ['iphone', 'ipad', 'itouch'],
            labels: ['iPhone', 'iPad', 'iPod Touch'],
            pointSize: 2,
            hideHover: 'auto',
            lineColors: [$rootScope.settings.color.themethirdcolor, $rootScope.settings.color.themesecondary, $rootScope.settings.color.themeprimary]
        });


        Morris.Bar({
            element: 'bar-chart',
            data: [
                { y: '2006', a: 100, b: 90, c: 80 },
                { y: '2007', a: 75, b: 65, c: 25 },
                { y: '2008', a: 50, b: 40, c: 90 },
                { y: '2009', a: 75, b: 65, c: 15 },
                { y: '2010', a: 50, b: 40, c: 50 },
                { y: '2011', a: 75, b: 65, c: 10 },
                { y: '2012', a: 100, b: 90, c: 90 }
            ],
            xkey: 'y',
            ykeys: ['a', 'b', 'c'],
            labels: ['Series A', 'Series B', 'Series C'],
            hideHover: 'auto',
            barColors: [$rootScope.settings.color.themeprimary, $rootScope.settings.color.themesecondary, $rootScope.settings.color.themethirdcolor]
        });

        Morris.Line({
            element: 'line-chart',
            data: $scope.tax_data,
            xkey: 'period',
            ykeys: ['licensed', 'sorned'],
            labels: ['Licensed', 'Off the road'],
            lineColors: [$rootScope.settings.color.themeprimary, $rootScope.settings.color.themethirdcolor]
        });


        Morris.Line({
            element: 'line-chart-2',
            data: [
                { y: '2006', a: 100, b: 90 },
                { y: '2007', a: 75, b: 65 },
                { y: '2008', a: 50, b: 40 },
                { y: '2009', a: 75, b: 65 },
                { y: '2010', a: 50, b: 40 },
                { y: '2011', a: 75, b: 65 },
                { y: '2012', a: 100, b: 90 }
            ],
            xkey: 'y',
            ykeys: ['a', 'b'],
            labels: ['Series A', 'Series B'],
            lineColors: [$rootScope.settings.color.themeprimary, $rootScope.settings.color.themethirdcolor]
        });


        Morris.Donut({
            element: 'donut-chart',
            data: [
                { label: 'IOS', value: 40, },
                { label: 'Win', value: 30 },
                { label: 'Android', value: 25 },
                { label: 'Java', value: 5 }
            ],
            colors: [$rootScope.settings.color.themeprimary, $rootScope.settings.color.themesecondary, $rootScope.settings.color.themethirdcolor, $rootScope.settings.color.themefourthcolor],
            formatter: function (y) { return y + "%"; }
        });
    }
]);